<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      padding: 50px;
    }
  </style>
</head>

<body>
  <div id="app"></div>
  <!-- 1.引入依赖 -->
  <script src="../../react/react.development.js"></script>
  <script src="../../react/react-dom.development.js"></script>
  <script src="../../react/babel.min.js"></script>
  <!-- 2.开始开发 -->
  <script type="text/babel">
    class App extends React.Component{
      constructor() {
        super()
        
        this.state = {
          count: 0
        }
      }

      render() {
        let {count} = this.state
        return (
          <div>
            <h3>当前计数:{count}</h3>
            <button onClick={this.increment.bind(this)}>+</button>
            <button onClick={this.decrement.bind(this)}>-</button>
          </div>
        )
      }

      increment() {
        this.setState({
          count: this.state.count+=1
        })
      }
      decrement() {
        this.setState({
          count: this.state.count-=1
        })
      }

    }
    ReactDOM.render(<App/>, document.getElementById('app'))
  </script>
</body>

</html>